<?php  
class UserController extends AuthController{
	private $db;
	public function __init(){
		$this->db=K('User');
	}
	/**
	 * 显示用户列表
	 * @return [type] [description]
	 */
	public function index(){
		$this->assign('user',$this->db->join('__user__ u JOIN __user_role__ ur JOIN __role__ r ON u.uid=ur.uid and ur.rid=r.rid')->all());
		$this->display();
	}
	public function edit(){
		if (IS_POST) {
			echo "待续...";exit;
		}else{
			$user=$this->db->join('__user__ u JOIN __role__ r ON u.rid=r.rid')->where('uid='.$_SESSION['uid'])->find();
			$this->assign('user',$user);
			$this->display();
		}
	}

	public function status(){
		if (M('user')->save()) {
			echo json_encode(array('status'=>1,'message'=>'修改成功'));exit;
		}else{
			echo json_encode(array('status'=>0,'message'=>'修改失败'));exit;
		}
	}
}
?>